#!/bin/bash
#
# Xiange Linux build scripts

# Short one-line description of this package.
DESCRIPTION="optimizer for php"

# Homepage, not used by Portage directly but handy for developer reference
HOMEPAGE="http://ops.dev.shopex.cn/"

# Point to any required sources; these will be automatically downloaded by
# gpkg. 
# $N = package name, such as autoconf, x-org
# $V = package version, such as 2.6.10

#SRC_URI="http://foo.bar.com/$N-$V.tar.bz2"
SRC_URI="http://mirrors.dev.shopex.cn/lnmpp/sources/zend-3.3.9.tar.gz"


# Binary package URI.
BIN_URI=""


# Runtime Depend
RDEPEND=""

# Build time depend
DEPEND="${RDEPEND}"



#init 
xgb_init()
{
	echo "init $N-$V$R build script..."
}

#unpack
xgb_unpack()
{
	#unpard file from $XGPATH_SOURCE to current directory.
	echo "Unpacking to `pwd`"
	tar xvf $XGPATH_SOURCE/`basename $SRC_URI`
}

#config
xgb_config()
{
    cd $N-$V$R
}

#build
xgb_build()
{
    return 0
}

#check
xgb_check()
{
	echo "checking $N-$V$R.."
	#make check
}

#install
xgb_install()
{
    echo "install to $XGPATH_DEST..."
    #install everything to $XGPATH_DEST
    F_DEST=$XGPATH_DEST/usr/local/zend
    mkdir -pv $F_DEST
    if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then
        cp 64/ZendOptimizer.so $F_DEST
    else
        cp 32/ZendOptimizer.so $F_DEST
    fi
}

#post install
xgb_postinst()
{
	echo "running after package installed..."
	cat >>/usr/local/php/etc/php.ini<<'EOF'
[Zend Optimizer]
zend_optimizer.optimization_level=1
zend_extension="/usr/local/zend/ZendOptimizer.so"
EOF
    service php-fpm stop
    service php-fpm start
}

#pre remove
xgb_prerm()
{
	echo "running before package delete..."
}

#post remove
xgb_postrm()
{
	echo "running after package delete..."
}
